# gateway.py
from py4j.java_gateway import JavaGateway, GatewayParameters

class Calculator:
    def add(self, a, b):
        return a + b

    def multiply(self, a, b):
        return a * b

if __name__ == "__main__":
    # 启动网关
    gateway = JavaGateway(gateway_parameters=GatewayParameters(port=25333))
    # 将 Calculator 类暴露给 Java
    gateway.entry_point = Calculator()
    # 保持网关运行
    print("Gateway started")
    gateway.close_callback_server()
    gateway.close()
